<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>子向父通讯</title>
</head>
<body>
    <div id="app">
        我现在的年龄是:{{age}}
        <info @yy="jia" @zz="jian"></info>
    </div>
    <script src="../node_modules/vue/dist/vue.js"></script>
    <script>

        let info = {
            template:
            `
                <div>
                    <button @click="add">点我加年龄</button>
                    <button @click="reduce">点我减年龄</button>
                </div>
            `,
            methods:{
                add(){
                    this.$emit("yy")
                },
                reduce(){
                   this.$emit("zz")
                }
            }

        }


        let app = new Vue({
            el:"#app",
            data:{
                age:18
            },
            components:{
                info
            },
            methods:{
                jia(){
                    this.age++
                },
                jian(){
                    this.age--
                }
            }


        });


    </script>
</body>
</html>